package com.cooge.jiexi;

import com.alibaba.fastjson.JSONObject;

public class Letv {

	public static void main(String[] args) throws Exception {
		
		//http://api.mob.app.letv.com/play?tm=1433383663&playid=0&tss=ios&pcode=010110041&version=5.8.3&pid=10000250
		//http://api.mob.app.letv.com/play?tm=1433383937&playid=0&tss=ios&pcode=010110041&version=5.8.3&pid=10004580&vid=22889816
		
		String linkurl = "http://www.letv.com/ptv/vplay/22689394.html";
		
		String  vid = linkurl.substring(linkurl.lastIndexOf("/"), linkurl.lastIndexOf(".")).replaceAll("[^0-9]", "");
		String playsurl = "http://api.mob.app.letv.com/play?tm="+System.currentTimeMillis()/1000+"&playid=0&tss=ios&pcode=010110041&version=5.8.3&vid="+vid;
		String source = NetUtil.getHtml(playsurl);
		JSONObject sobj = JSONObject.parseObject(source);
		JSONObject body = sobj.getJSONObject("body");
		JSONObject videofile =  body.getJSONObject("videofile");
		JSONObject infos = videofile.getJSONObject("infos");
		if(infos.containsKey("mp4_180")){
			String mainurl =  infos.getJSONObject("mp4_180").getString("mainUrl");
			String playurl = JSONObject.parseObject(NetUtil.getHtml(mainurl)).getString("location");
			System.out.println(playurl);
		}
		if(infos.containsKey("mp4_350")){
			String mainurl =  infos.getJSONObject("mp4_350").getString("mainUrl");
			String playurl = JSONObject.parseObject(NetUtil.getHtml(mainurl)).getString("location");
			System.out.println(playurl);
		}
		if(infos.containsKey("mp4_1000")){
			String mainurl =  infos.getJSONObject("mp4_1000").getString("mainUrl");
			String playurl = JSONObject.parseObject(NetUtil.getHtml(mainurl)).getString("location");
			System.out.println(playurl);
		}
		if(infos.containsKey("mp4_1300")){
			String mainurl =  infos.getJSONObject("mp4_1300").getString("mainUrl");
			String playurl = JSONObject.parseObject(NetUtil.getHtml(mainurl)).getString("location");
			System.out.println(playurl);
		}

	}

}
